package com.sinooceangroup.capital.sentinel.feign;

import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * {@link ProductorFeignClient} fallback factory
 *
 * @author: Leo.Wang, adwyxx@qq.com
 * @date: 2020/8/6 9:14
 */
@Component
public class ProductorFeignClientFallbackFactory implements FallbackFactory<ProductorFeignClient> {
    /***
     * 服务降级处理
     * fallbackFactory 可以拿到异常信息
     * fallback 无法拿到异常信息
     * @param throwable: 服务提供者Api接口异常信息
     * @return
     */
    @Override
    public ProductorFeignClient create(Throwable throwable) {
        return new ProductorFeignClient() {
            @Override
            public String sentinelFeign() {

                return "FallbackFactory handled!! \t"+ throwable.getMessage();
            }
        };
    }
}
